//
//  DHPickerVC.m
//  NavigationDemo
//
//  Created by 证联 on 2022/7/25.
//

#import "DHPickerVC.h"

@interface DHPickerVC ()<UIPickerViewDelegate,UIPickerViewDataSource>
@property (weak, nonatomic) IBOutlet UIPickerView *pickerView;
@property (strong ,nonatomic)NSArray *arr;

@end

@implementation DHPickerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.barTitle=@"选择器";
    self.arr = @[@"SDK",@"手机",@"地方",@"肥嘟嘟",@"地方百度",@"得而非",@"是多少",@"啥都好说"];
    //设置代理
    self.pickerView.delegate = self;
    //设置数据源
    self.pickerView.dataSource = self;
    NSLog(@"%@", self.arr[1]);
    
}
#pragma mark - UIPickerViewDataSource
//组件的轮数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}
//返回组件行数，实际就是数据源数组的count
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    return  self.arr.count;
}

#pragma mark - UIPickerViewDelegate

//给组件设置每行的内容
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    return  self.arr[row];
}
// 每列宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{
    return 150;
}
//选择的行
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    NSLog(@"选中==%@", self.arr[row]);
}
//确定按钮
- (IBAction)confirm:(id)sender {
    
}

@end
